import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 学生用户信息 */
export interface Student {
          id: number; // 主键
          parentId: number; // wx_user 家长ID
          studentName: string; // 学生姓名
          studentBirthdate: string | Dayjs; // 出生日期
          studentAge: number; // 年龄
          studentPhoneNumber: number; // 手机号码
          studentSex: boolean; // 学生性别（0男 1女 2未知）
          studentStatus: boolean; // 帐号状态（0正常 1停用）
  }

// 学生用户 API
export const StudentApi = {
  // 查询学生用户分页
  getStudentPage: async (params: any) => {
    return await request.get({ url: `/train/student/page`, params })
  },

  // 查询学生用户详情
  getStudent: async (id: number) => {
    return await request.get({ url: `/train/student/get?id=` + id })
  },

  // 新增学生用户
  createStudent: async (data: Student) => {
    return await request.post({ url: `/train/student/create`, data })
  },

  // 修改学生用户
  updateStudent: async (data: Student) => {
    return await request.put({ url: `/train/student/update`, data })
  },

  // 删除学生用户
  deleteStudent: async (id: number) => {
    return await request.delete({ url: `/train/student/delete?id=` + id })
  },

  /** 批量删除学生用户 */
  deleteStudentList: async (ids: number[]) => {
    return await request.delete({ url: `/train/student/delete-list?ids=${ids.join(',')}` })
  },

  // 导出学生用户 Excel
  exportStudent: async (params) => {
    return await request.download({ url: `/train/student/export-excel`, params })
  }
}
